<template>
  <div>
    <van-nav-bar
      title="房屋管理"
      left-text="返回"
      right-text="按钮"
      left-arrow
      @click-left="$router.back()"
    />
    <HouseMudule :list="list" v-if="show"></HouseMudule>
    <div class="defult" v-else>
      <div class="pic">
        <img src="http://liufusong.top:8080/img/not-found.png" alt="">
      </div>
      <div class="txt">您还没有发布房源，<a href="#/fangyuan" >去发布房源</a> 吧</div>
    </div>
  </div>
</template>

<script>
import { houseList } from '@/api/house'
import HouseMudule from '@/components/housemudule.vue'
export default {
  name: 'MyHouse',
  components: {
    HouseMudule
  },
  data () {
    return {
      list: [],
      show: true
    }
  },
  async created () {
    const res = await houseList()
    res.body.forEach(item => {
      item.houseImg = 'http://liufusong.top:8080' + item.houseImg
    })
    this.list = res.body
    if (this.list.length === 0) {
      this.show = false
    }
  }
}
</script>

<style lang= 'less' scoped>
.defult{
  width: 100%;
  margin-top: 20px;
  .pic{
    width: 180px;
    margin:0 auto ;
    text-align: center;
  img{
    width: 180px;
  }

}
.txt{
  padding-top: 20px;
    width: 100%;
    margin:0 auto ;
    text-align: center;
    a{
      color: #21b97a;
    }
  }
}

</style>
